package com.fantuan.weixin.bean;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

public class InMessage {

	public InMessage( String content )
	{
		Document doc = Jsoup.parse(content);
		this.toUserName = doc.getElementsByTag("ToUserName").get(0).text();
		this.fromUserName = doc.getElementsByTag("FromUserName").get(0).text();
		this.createTime = NumberUtils.toLong(doc.getElementsByTag("CreateTime").get(0).text()) * DateUtils.MILLIS_PER_SECOND;
		this.msgType = doc.getElementsByTag("MsgType").get(0).text();
		this.msgID = NumberUtils.toLong(doc.getElementsByTag("MsgId").get(0).text());
	}
	
	//开发者微信号
	private String toUserName;
	public String getToUserName() {
		return toUserName;
	}
	public void setToUserName(String toUserName) {
		this.toUserName = toUserName;
	}
	public String getFromUserName() {
		return fromUserName;
	}
	public void setFromUserName(String fromUserName) {
		this.fromUserName = fromUserName;
	}
	public long getCreateTime() {
		return createTime;
	}
	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}
	public String getMsgType() {
		return msgType;
	}
	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}
	public long getMsgID() {
		return msgID;
	}
	public void setMsgID(long msgID) {
		this.msgID = msgID;
	}
	//发送方帐号（一个OpenID）
	private String fromUserName;
	//消息创建时间 （整型）,10位，转换+000
	private long createTime;
	private String msgType;
	//消息id，64位整型
	private long msgID;
	
	
	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}

}
